package reflect;

import java.lang.reflect.Method;

/**
 * 反射机制调用的参数
 */
public class ReflectDemo5 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();

        //public void say(String info){}
        Method method = cls.getMethod("say", String.class);
        method.invoke(obj, "hello"); //obj.say("hello");

        //public void say(String info,int count){}
        Method method2 = cls.getMethod("say", String.class, int.class);
        method2.invoke(obj, "你好", 5);
    }
}
